package week5;

/**
 * Created by dell on 2017/3/25.
 */
//子类覆盖父类方法，父类方法抛出异常，子类的覆盖方法可以不抛出异常
class Father2 {
    void test() throws ClassNotFoundException { // 非运行时异常
        System.out.println("父类");
        throw new ClassNotFoundException();
    }
}

class Son2 extends Father2 {
    void test() {
        System.out.println("子类");
        // 父类方法有异常，子类没有。
    }
}
public class Demo2 {
    public static void main(String[] args) throws ClassNotFoundException  {
        Father2 f = new Son2();
        f.test();
        /*Father2 f2 = new Father2();
        f2.test();*/
    }
}